package com.javatest.redpacket.dao;

import com.javatest.redpacket.entities.RedPacket;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @date 2020-08-03 下午5:05
 */
@Repository
public interface RedPacketDao {
    /**
     * Gets red packet.
     *
     * @param id the id
     * @return the red packet
     */
    RedPacket getRedPacket(@Param("id") Long id);

    /**
     * 启用悲观锁的方式查询
     * Gets red packet for update.
     *
     * @param id the id
     * @return the red packet for update
     */
    RedPacket getRedPacketForUpdate(@Param("id") Long id);

    /**
     * Decrease red packet int.
     *
     * @param id the id
     * @return the int
     */
    int decreaseRedPacket(@Param("id") Long id);

    /**
     * Decrease red packet for version.
     *
     * @param id      the id
     * @param version the version
     * @return the int
     */
    int decreaseRedPacketForVersion(@Param("id") Long id, @Param("version") Integer version);
}
